package com.yxy.service;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.yxy.utils.ZxingUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;

@Service
public class ZxingService {


    @Autowired
    ZxingUtils zxingUtils;

    public  String generateQRCodeImage() throws WriterException, IOException {


        String text = "黄鑫绒";
        String  imageName = "huangxinrong.png";
        int width = 350;
        int height= 350;
        try {
            zxingUtils.generateQRCodeImage(text, width, height,imageName);
        } catch (WriterException e) {
            System.out.println("Could not generate QR Code, WriterException :: " + e.getMessage());
        } catch (IOException e) {
            System.out.println("Could not generate QR Code, IOException :: " + e.getMessage());
        }

        return  "生成成功！";
    }

}
